package com.dynamixsoftware.printershare.data;

import android.graphics.Rect;
import com.dynamixsoftware.printershare.data.XmlUtil;
import org.w3c.dom.Element;

public class Paper implements Comparable<Paper> {

	public boolean custom;
	public String drv_params;
	public int height;
	public String id;
	public Rect image_area;
	public String name;
	public int width;

	public Paper() {
	}

	public Paper(String paramString1, String paramString2, int paramInt1, int paramInt2, Rect paramRect) {
		this.id = paramString1;
		this.name = paramString2;
		this.width = paramInt1;
		this.height = paramInt2;
		this.image_area = paramRect;
	}

   public int compareTo(Paper var1) {
      return this.name.compareTo(var1.name);
   }

   public void readFromXml(Element var1) {
      this.id = var1.getAttribute("format");
      this.width = Integer.parseInt(var1.getAttribute("width"));
      this.height = Integer.parseInt(var1.getAttribute("height"));
      String var2 = var1.getAttribute("area-x");
      String var3 = var1.getAttribute("area-y");
      String var4 = var1.getAttribute("area-width");
      String var5 = var1.getAttribute("area-height");
      int var6;
      if(var2 != null && var2.length() != 0) {
         var6 = Integer.parseInt(var2);
      } else {
         var6 = 0;
      }

      int var7 = 0;
      if(var3 != null) {
         int var10 = var3.length();
         var7 = 0;
         if(var10 != 0) {
            var7 = Integer.parseInt(var3);
         }
      }

      int var8;
      if(var4 != null && var4.length() != 0) {
         var8 = Integer.parseInt(var4);
      } else {
         var8 = this.width;
      }

      int var9;
      if(var5 != null && var5.length() != 0) {
         var9 = Integer.parseInt(var5);
      } else {
         var9 = this.height;
      }

      this.image_area = new Rect(var6, this.height - var9 - var7, var6 + var8, this.height - var7);
      this.custom = "true".equals(var1.getAttribute("custom"));
      if(var1.hasAttribute("name")) {
         this.name = var1.getAttribute("name");
      } else {
         this.name = XmlUtil.getNodeValue(var1);
         if("256".equals(this.id)) {
            this.custom = true;
            return;
         }
      }

   }
}
